# 普通方法实现

import requests
# 部门列表
url='http://ihrm2-test.itheima.net/api/company/department'
headers= {"Authorization": "xxxxxxx"}
resp = requests.get(url=url, headers=headers)
print(resp.json())

# 添加部门
url = 'http://ihrm2-test.itheima.net/api/company/department'
headers = {"Content-Type": "application/json", "Authorization": "xxxxxxx"}
body={"name":"猪猪部门","code":"9999"}
resp = requests.post(url=url, headers=headers, json=body)
print(resp.json())


# 查询部门
url = 'http://ihrm2-test.itheima.net/api/company/department/dep_id'
headers = {"Authorization": "xxxxxxx"}
resp = requests.get(url=url, headers=headers)
print(resp.json())


# 修改部门
url = 'http://ihrm2-test.itheima.net/api/company/department/dep_id'
headers = {"Content-Type": "application/json", "Authorization": "xxxxxxx"}
body = {"name": "傻子部门", "code": "9999"}
resp = requests.put(url=url, headers=headers, json=body)
print(resp.json())


# 删除部门
url = 'http://ihrm2-test.itheima.net/api/company/department/dep_id'
headers = {"Authorization": "xxxxxxx"}
resp = requests.delete(url=url, headers=headers)
print(resp.json())



